<?php
require_once '../Config/config.php';

class DB {

    public $test = "It's DB class";
    public $connection;

    public function getConnection() {
        
        $this->connection = mysql_connect(DB_HOST . ":" . DB_PORT, DB_USER, DB_PASS) or die(mysql_error());
        mysql_select_db(DB_NAME, $this->connection);
        return $this->connection;
    }

    public function query($query) {
        mysql_query('SET NAMES utf8', $this->connection);
        $data = mysql_query($query, $this->connection);
        $rows = array();
        if (is_bool($data)) return array();
        while ($row = mysql_fetch_assoc($data)) {
            $rows[] = $row;
        }
        return $rows;
    }
}